package com.qimo.service.Impl;

import com.qimo.dao.ItemDao;
import com.qimo.dao.ShoppingCartDao;
import com.qimo.model.ShoppingCartList;
import com.qimo.service.ShoppingCartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("shoppingCartService")
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Resource
    private ShoppingCartDao shoppingCartDao;


    public int addShoppingCart(int userId, int itemId) {
        System.out.println("userId="+userId);
        System.out.println("itemId="+itemId);
        return shoppingCartDao.addShoppingCart(userId,itemId);
    }

    public int alterShoppingCartNumber(int userId, int itemId,int Number) {
    if(Number<=0)
        return -999;
        return this.shoppingCartDao.alterShoppingCartNumber(userId,itemId,Number);
    }

    public int delShoppingCart(int userId, int itemId) {
        return this.shoppingCartDao.delShoppingCart(userId,itemId);
    }

    public int selectShoppingCart(int userId) {
        return shoppingCartDao.selectShoppingCartNumber(userId);
    }

    public List<ShoppingCartList> ShoppingCartList(int userId,int Page)
    {
        System.out.println(userId+","+Page);
        return shoppingCartDao.ShoppingCartList(userId,(Page-1)*4);
    }
}
